package com.example.demo.design.mediator;

/**
 * @Author: liull
 * @Description:
 * @Date: Created in 14:56 2021/4/6
 * @Modified By:
 */
public class ConcreteMediator extends Mediator {
    // 维持对各个同事对象的引用
    public List list;

    public Button button;

    public TextBox usernameTextBox;

    public ComboBox comboBox;

    @Override
    public void componentChanged(Component c) {
        if (c == button) { // 单机按钮
            System.out.println("--单机增加按钮--");
            list.update();
            comboBox.update();
            usernameTextBox.update();
        } else if (c == list) {
            System.out.println("--从列表框选择用户--");
            comboBox.select();
            usernameTextBox.setText();
        } else if (c == comboBox) {
            System.out.println("--从组合框选择客户--");
            comboBox.select();
            usernameTextBox.setText();
        }
    }
}
